var IntelligentTool = require('./IntelligentTool');
var _ = require('./Underscore');
var CardTool = require('./CardTool');
var FindPairsTool = require('./FindTool/FindPairsTool');

function domain() {

    /**生成一幅牌 */
    var allCards = [];
    for (var cardId = 1; cardId <= 65; ++cardId) {
        allCards.push(cardId);
        var type = CardTool.getCardType(cardId);
        var value = CardTool.getCardValue(cardId);
        // console.error('cardId: %d  类型:%d  牌值:%d', cardId, type, value);
    }
    /**************************************************/
    var randCards = [];
    //随机13个牌
    for (var randNum = 1; randNum <= 13; ++randNum) {
        var maxNum = _.size(allCards);
        var idx = _.random(0, maxNum - 1);
        var randCardId = allCards[idx];
        randCards.push(randCardId);
        allCards = _.without(allCards, randCardId);
        // console.error("剩下的牌:", JSON.stringify(allCards));
    }

    // randCards = [1, 29, 31, 9, 37, 34, 55, 58, 18, 26, 59, 22, 17];
    // randCards = [52, 13, 25, 8, 44, 10, 12, 63, 49, 29, 31, 15, 60]

    //本地做牌
    // randCards = [1, 1 + 13, 1 + 13 * 2, 1 + 13 * 3, 1 + 13 * 4, 2, 2 + 13, 2 + 13 * 2, 2 + 13 * 3, 2 + 13 * 4, 18, 19, 60]

    // A同花
    // randCards = [10, 55, 3, 51, 39, 18, 19, 54, 7, 43, 6, 17, 12]

    // randCards = [57, 43, 38, 23, 11, 3, 5, 4, 18, 33, 65, 64, 17]

    // randCards = [1, 2, 3, 4, 5, 14, 15, 18];
    // CardTool.Log(randCards, '最终随机出的牌');

    // randCards = IntelligentTool.check(randCards)
    IntelligentTool.getResult(randCards, 3);


    // var duizi = FindPairsTool.getResult(randCards, 1);
    // CardTool.LogResult(duizi, "对子");
    // CardTool.Log(randCards, '最终随机出的牌');
}
domain();